﻿using B.S.DataBase.MyProject.Domain.wdx.ViewModels;
using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using MedicalPCTerminal.Read.API.Appcation.Commands.ResidentCommand;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MedicalPCTerminal.Read.API.Controllers
{
    /// <summary>
    /// 居民档案控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize]
    public class ResidentFilesController : ControllerBase
    {
        private readonly IMediator mediator;

        public ResidentFilesController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 获取居民档案列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiPaging<View_ResidentFileList>> GetResidentFilesList([FromQuery] GetResidentFilesListCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 获取居民档案详情
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<View_ResidentFileDetail>> GetResidentFilesDetail([FromQuery] GetResidentFilesDetailCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 根据居民名字获取居民档案信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<View_GetResident>> GetResident([FromQuery]GetResidentCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
